<template>
    <div class="">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-message"></i>&nbsp;新增设备分类</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        
        <div class="container">
            <el-form ref="form" label-width="120px">
                
                <el-form-item label="设备分类：">
                    <el-input v-model="title" placeholder="请输入设备分类" style="width:400px"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submit">确认发布</el-button>
                </el-form-item>
            </el-form>
        </div>
        
    </div>
</template>
<script>
import {deviceCategoryAdd} from '@/api/device';
export default {
    name:"deviceCategoryAdd",
    data() {
        return {
            typeId:'', //当前要删除图片的类型   1封面图 2详情图  3关键词
            idx:0,//当前记录的下标
            delVisible:false,
            fullscreenLoading:false,
            delVisible:false,
            title:'',//分类
            
        }
    },
    components: {

    },
    //实例创建
    created(){
        // editor.create()
    },
    //计算属性
    computed:{
		
    },
    //方法
    methods: {
        //确认发布
        submit(){
// console.log(this.$refs.vueWangeditor.getText().length);
            if(this.title==""){
                this.$notify.info({title: '提示',message: '请输入设备分类名称'});
                return false;
            }
            else{
                let param ={}
                param.title=this.title;
                this.saveGoods(param);
            }
        },
        //提交信息上传
        saveGoods(param){
            var _this =this;
            deviceCategoryAdd(param).then(response=>{
                // console.log(response);
                if(response.code==200){
                    this.$message({
                        message: '恭喜你，发布成功',
                        type: 'success'
                    });
                    setTimeout(function(){
                         _this.$router.push('/device/category');
                    },1500);

                }else{
                    this.$notify.error({
                        title: '发布失败',
                        duration:2000,
                        message: '失败原因：'+response.msg
                    });
                }

            }).catch(error=>{
                console.log(error);
            });
        },
    }
}
</script>
<style>
    
</style>


